package cn.com.gas.service.impl;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cn.com.gas.entity.GasStaytimeResultEntity;
import cn.com.gas.mapper.GasStaytimeResultMapper;
import cn.com.gas.service.GasStaytimeResultService;

@Service("gasStaytimeResultService")
public class GasStaytimeResultServiceImpl extends ServiceImpl<GasStaytimeResultMapper, GasStaytimeResultEntity>
		implements GasStaytimeResultService {

	@Autowired
	private GasStaytimeResultMapper gasStaytimeResultMapper;

	@Override
	public List<GasStaytimeResultEntity> groupYearMonthOline(String taxorgcode) {
		return gasStaytimeResultMapper.groupYearMonthOline(taxorgcode);
	}

	@Override
	public List<GasStaytimeResultEntity> groupYearMonthDiesel(String taxorgcode) {
		return gasStaytimeResultMapper.groupYearMonthDiesel(taxorgcode);
	}

	@Override
	public List<GasStaytimeResultEntity> listLimit(List<String> stationinfoIdList,
			GasStaytimeResultEntity gasStaytimeResult) throws ParseException {
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		gasStaytimeResult.setCreateTimeEndDate(sdf.parse(gasStaytimeResult.getCreateTimeEnd() + " 00:00:00"));
		gasStaytimeResult.setCreateTimeStartDate(sdf.parse(gasStaytimeResult.getCreateTimeStart() + " 23:59:59"));
		
		return gasStaytimeResultMapper.listLimit(stationinfoIdList, gasStaytimeResult);
		
	}

	@Override
	public List<GasStaytimeResultEntity> listCount(List<String> stationinfoIdList,
			GasStaytimeResultEntity gasStaytimeResult) throws ParseException {
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		gasStaytimeResult.setCreateTimeEndDate(sdf.parse(gasStaytimeResult.getCreateTimeEnd() + " 00:00:00"));
		gasStaytimeResult.setCreateTimeStartDate(sdf.parse(gasStaytimeResult.getCreateTimeStart() + " 23:59:59"));
		
		return gasStaytimeResultMapper.listCount(stationinfoIdList, gasStaytimeResult);
	}

}